﻿Imports utilitiesLibrary
Imports System.Data.SqlClient

Public Class customer
    Inherits System.Web.UI.Page

    Dim ds As New DataSet
    Dim objDB As New DBConnect
    Dim sql As String
    Dim dr As SqlDataReader

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        objDB = Session("db")

        If Not IsPostBack Then
            lblCustInfo.Visible = False

        End If
    End Sub

    Protected Sub btnNewCust_Click(sender As Object, e As EventArgs) Handles btnNewCust.Click
        objDB = Session("db")
        Dim newAcctId As Integer

        sql = "INSERT INTO  customers VALUES('" & txtCustName.Text & "')"
        objDB.doUpdate(sql)
        sql = "Select @@Identity as Num"
        dr = objDB.getDataReader(sql)
        dr.Read()
        newAcctId = dr("Num")
        dr.Close()
       
        sql = "INSERT INTO FreqFlier (AccountID, FFMiles) VALUES (" & newAcctId & ", 0)"
        'MsgBox(sql)
        objDB.doUpdate(sql)
        lblCustInfo.Text = "New customer " & "<b>" & txtCustName.Text & "</b>" & " created with account id of: " & "<b>" & newAcctId & "</b>"
        lblCustInfo.Visible = True


    End Sub
End Class